/*
 * Copyright (C) 2010-2012 Susanta Tewari
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.nb.jobs1;

import cef.command.Command;
import cef.command.Model_MLE_Command;
import cef.pui.EventConstructionException;
import coalescent.cef.command.MLE_K69ThetaCommand;
import coalescent.cef.command.listener.K69_MLE_OLs;
import coalescent.cef.pui.K69_MLE_EventImpl;
import coalescent.cef.pui.MLE_KC64ThetaEventImpl;
import coalescent.cef.pui.pob.Builders_Coa;
import coalescent.nb.jobs.properties.ComboPropertys_Coa;
import coalescent.nb.jobs.properties.Propertys_Coa;
import commons.nb.jobs.Job;
import commons.nb.jobs.gui.JobsGUIUtil;

import java.util.Properties;

/**
 * @since 1.4.0
 * @version version
 * @author Susanta Tewari
 * @history Created on Dec 10, 2012.
 */
public final class MLE_K69ThetaJob extends Job<K69_MLE_EventImpl> {

    public MLE_K69ThetaJob() {

        setName("mle-k69-theta");
        setDisplayName("<b>MLE-Infinite-Sites (K69)</b>");
        setShortDescription("Computes MLE for Infinite-Sites (K69) Model.");


        // data
        addComboProperty(Propertys_Coa.of_Builder_K69Data("coalescent.builder.K69Data"));


        // theta-range
        addComboProperty(ComboPropertys_Coa.K69List("coalescent.builder.K69List.theta"));


        // listeners
        addCommandOutputListener(new K69_MLE_EventImpl.CollectExactProb());    // meta-inf
        addCommandOutputListener(new K69_MLE_OLs.PW());
        addCommandOutputListener(JobsGUIUtil.makeEmbeddable(new K69_MLE_OLs.OC()));
    }

    @Override
    public Properties getProperties() {

        final Properties props = super.getProperties();

        props.setProperty("coalescent.builder.K69MultiLHood.implCode", "exact-recursion-multi");


        // meta-inf
        props.setProperty("coalescent.MetaInf.active", "true");
        props.setProperty("coalescent.MetaInf_K69Data.delegate",
                          Builders_Coa.MetaInfMngr_K69Data_File.class.getName());
        props.setProperty("coalescent.MetaInf_K69Data.url", "key:coalescent.builder.K69Data.url");

        return props;
    }

    @Override
    public boolean isCancellable() {
        return MLE_K69ThetaCommand.isCancellable();
    }

    @Override
    protected K69_MLE_EventImpl createEvent() throws EventConstructionException {
        return new K69_MLE_EventImpl(getProperties());
    }

    @Override
    public Class<MLE_KC64ThetaEventImpl> getEventImplType() {
        return MLE_KC64ThetaEventImpl.class;
    }

    @Override
    protected Command createCommand(final K69_MLE_EventImpl event) {
        return new Model_MLE_Command<>(event);
    }
}
